package fr.uniscol.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class DefaultUser implements IUniscolUser, Serializable {

	private long id = 0;
	
	private String login = null;
	
	private String password = null;
	
	private BaseAnneeScolaire baseSelectionnee = null;
	
	private String nom = null;
    
    private String prenom = null;

	private boolean authentifie = false;
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	@Override
	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	@Override
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public EtablissementModel getEtablissement() {
		if(baseSelectionnee != null){
			return baseSelectionnee.getEtablissement();
		}
		return null;
	}

	public BaseAnneeScolaire getBaseSelectionnee() {
		return baseSelectionnee;
	}

	public void setBaseSelectionnee(BaseAnneeScolaire baseSelectionnee) {
		this.baseSelectionnee = baseSelectionnee;
	}

    public String getNom() {
        if(nom == null){
            nom = "";
        }
        return nom;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public String getPrenom() {
        if(prenom == null){
           prenom = ""; 
        }
        return prenom;
    }

    public void setPrenom(String prenom) {
        this.prenom = prenom;
    }

	@Override
	public String getIdentite() {
		return getPrenom() + " " + getNom();
	}

	public boolean isAuthentifie() {
		return authentifie;
	}

	public void setAuthentifie(boolean authentifie) {
		this.authentifie = authentifie;
	}

    @Override
    public boolean isSuperAdmin() {
        return false;
    }

    @Override
    public void setIdentite(String identite) {
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 67 * hash + (int) (this.id ^ (this.id >>> 32));
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final DefaultUser other = (DefaultUser) obj;
        if (this.id != other.id) {
            return false;
        }
        return true;
    }
}
